//
//  RdbViewUtils.swift
//  rdb-led-banner
//
//  Created by radiobox3 on 2025/4/18.
//

import UIKit

class RdbViewUtils: NSObject {
    
    static let shared = RdbViewUtils()
    
    
    func createStackView(views: [UIView],direction: NSLayoutConstraint.Axis, alignment: UIStackView.Alignment,spacing: CGFloat = 10.0) -> UIStackView {
        let stack = UIStackView(arrangedSubviews: views)
        stack.axis = direction
        stack.alignment = alignment
        stack.spacing = spacing
        return stack
    }
    
    func createCircleButton(fontSize: CGFloat,
                            title: String,
                            cornerRadius: CGFloat,
                            backgroundColor: String,
                            target: Any?,
                            action: Selector) -> UIButton {
        let  button = UIButton(type: .roundedRect)
        button.setTitleColor(UIColor.white, for: .normal)
        button.titleLabel?.font = UIFont.semibold(fontSize)
        button.setTitle(title, for: .normal)
        button.contentHorizontalAlignment = .center
        button.titleLabel?.textAlignment = .center
        button.layer.cornerRadius = cornerRadius
        button.clipsToBounds = true
        button.backgroundColor = UIColor(backgroundColor)
        button.addTarget(target, action: action, for: .touchUpInside)
        return button
    }
    
    func createPrivacyPolicy() -> RdbWebViewController {
        let webviewController = RdbWebViewController(url: URL(string: Constants.privacy_url))
        webviewController.title = "setting_policy".localized
        webviewController.hidesBottomBarWhenPushed = true
        return webviewController
    }
    func createTermService() -> RdbWebViewController {
        let webviewController = RdbWebViewController(url: URL(string: Constants.service_url))
        webviewController.title = "setting_terms".localized
        webviewController.hidesBottomBarWhenPushed = true
        return webviewController
    }
}
